home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / misc / date.lha / Date / M2 / txt / testDate.mod < prev    next >
Text File  |  1994-08-11  |  14KB  |  380 lines

  1.  MODULE test;
  2.  
  3.  
  4.  FROM InOut    IMPORT    WriteInt,WriteCard,WriteString,WriteLn,
  5.             ReadCard,ReadInt,ReadLongCard;
  6.  FROM RealInOut    IMPORT    WriteReal,ReadReal;
  7.  IMPORT Date;
  8.  
  9.  
  10.  PROCEDURE readintyear() : INTEGER;
  11.  
  12.  VAR
  13.     year    : INTEGER;
  14.  
  15.  BEGIN
  16.    WriteString("(integer)year: "); ReadInt(year);
  17.    RETURN(year);
  18.  END readintyear;
  19.  
  20.  
  21.  PROCEDURE readshortcardmonth() : SHORTCARD;
  22.  
  23.  VAR
  24.     month    : CARDINAL;
  25.  
  26.  BEGIN
  27.    WriteString("(shortcard)month: "); ReadCard(month);
  28.    RETURN(SHORTCARD(month));
  29.  END readshortcardmonth;
  30.  
  31.  
  32.  PROCEDURE readshortcardday() : SHORTCARD;
  33.  
  34.  VAR
  35.     day    : CARDINAL;
  36.  
  37.  BEGIN
  38.    WriteString("(shortcard)day: "); ReadCard(day);
  39.    RETURN(SHORTCARD(day));
  40.  END readshortcardday;
  41.  
  42.  
  43.  PROCEDURE readweekday() : Date.Weekdays;
  44.  
  45.  VAR
  46.     wday    : CARDINAL;
  47.  
  48.  BEGIN
  49.    REPEAT
  50.      WriteString("weekday: 1=Monday; ...7=Sunday: "); ReadCard(wday);
  51.    UNTIL wday < 8;
  52.    RETURN(Date.Weekdays(wday));
  53.  END readweekday;
  54.  
  55.  
  56.  PROCEDURE readintdays() : INTEGER;
  57.  
  58.  VAR
  59.     days    : INTEGER;
  60.  
  61.  BEGIN
  62.    WriteString("(integer)days: "); ReadInt(days);
  63.    RETURN(days);
  64.  END readintdays;
  65.  
  66.  
  67.  PROCEDURE readcardyear() : CARDINAL;
  68.  
  69.  VAR
  70.     year    : CARDINAL;
  71.  
  72.  BEGIN
  73.    WriteString("(cardinal)year: "); ReadCard(year);
  74.    RETURN(year);
  75.  END readcardyear;
  76.  
  77.  
  78.  PROCEDURE readlongcarddays() : LONGCARD;
  79.  
  80.  VAR
  81.     day    : LONGCARD;
  82.  
  83.  BEGIN
  84.    WriteString("(longcard)days: "); ReadLongCard(day);
  85.    RETURN(day);
  86.  END readlongcarddays;
  87.  
  88.  
  89.  PROCEDURE readshortcardhour() : SHORTCARD;
  90.  
  91.  VAR
  92.     hour    : CARDINAL;
  93.  
  94.  BEGIN
  95.    WriteString("(shortcard)hour: "); ReadCard(hour);
  96.    RETURN(SHORTCARD(hour));
  97.  END readshortcardhour;
  98.  
  99.  
  100.  PROCEDURE readshortcardmin() : SHORTCARD;
  101.  
  102.  VAR
  103.     min    : CARDINAL;
  104.  
  105.  BEGIN
  106.    WriteString("(shortcard)min: "); ReadCard(min);
  107.    RETURN(SHORTCARD(min));
  108.  END readshortcardmin;
  109.  
  110.  
  111.  PROCEDURE readshortcardsec() : SHORTCARD;
  112.  
  113.  VAR
  114.     sec    : CARDINAL;
  115.  
  116.  BEGIN
  117.    WriteString("(shortcard)sec: "); ReadCard(sec);
  118.    RETURN(SHORTCARD(sec));
  119.  END readshortcardsec;
  120.  
  121.  
  122.  PROCEDURE readrealtime() : REAL;
  123.  
  124.  VAR
  125.     jd    : REAL;
  126.  
  127.  BEGIN
  128.    WriteString("(real)time: "); ReadReal(jd);
  129.    RETURN(jd);
  130.  END readrealtime;
  131.  
  132.  
  133.  PROCEDURE readshortintdegree() : SHORTINT;
  134.  
  135.  VAR
  136.     degree    : INTEGER;
  137.  
  138.  BEGIN
  139.    WriteString("(shortint)degree: "); ReadInt(degree);
  140.    RETURN(SHORTINT(degree));
  141.  END readshortintdegree;
  142.  
  143.  
  144.  PROCEDURE readlongcardsecs() : LONGCARD;
  145.  
  146.  VAR
  147.     secs    : LONGCARD;
  148.  
  149.  BEGIN
  150.    WriteString("(longcard)secs: "); ReadLongCard(secs);
  151.    RETURN(secs);
  152.  END readlongcardsecs;
  153.  
  154.  
  155.  PROCEDURE readrealmeridian() : REAL;
  156.  
  157.  VAR
  158.     jd    : REAL;
  159.  
  160.  BEGIN
  161.    WriteString("(real)meridian: "); ReadReal(jd);
  162.    RETURN(jd);
  163.  END readrealmeridian;
  164.  
  165.  
  166.  PROCEDURE readrealpos() : REAL;
  167.  
  168.  VAR
  169.     jd    : REAL;
  170.  
  171.  BEGIN
  172.    WriteString("(real)ps: "); ReadReal(jd);
  173.    RETURN(jd);
  174.  END readrealpos;
  175.  
  176.  
  177.  VAR
  178.     input,repeat    : CARDINAL;
  179.     wd        : Date.Weekdays;
  180.     d,m,h,s        : SHORTCARD;
  181.     y        : INTEGER;
  182.  
  183.  
  184.  BEGIN
  185.    REPEAT
  186.      WriteString("----------------------------------------------------------------\n");
  187.      WriteString("01 : JulianLeapYear            | 02 : GregorianLeapYear\n");
  188.      WriteString("03 : HeisLeapYear              | 04 : JulianMonthDays\n");
  189.      WriteString("05 : GregorianMonthDays        | 06 : HeisMonthDays\n");
  190.      WriteString("07 : JulianYearDays            | 08 : GregorianYearDays\n");
  191.      WriteString("09 : HeisYearDays              | 10 : JulianDayDiff\n");
  192.      WriteString("11 : GregorianDayDiff          | 12 : HeisDayDiff\n");
  193.      WriteString("13 : JulianDaySmaller          | 14 : GregorianDaySmaller\n");
  194.      WriteString("15 : HeisDaySmaller            | 16 : JulianWeekday\n");
  195.      WriteString("17 : GregorianWeekday          | 18 : HeisWeekday\n");
  196.      WriteString("19 : JulianDaysBeforeWeekday   | 20 : GregorianDaysBeforeWeekday\n");
  197.      WriteString("21 : HeisDaysBeforeWeekday     | 22 : JulianDaysAfterWeekday\n");
  198.      WriteString("23 : GregorianDaysAfterWeekday | 24 : HeisDaysAfterWeekday\n");
  199.      WriteString("25 : JulianDiffDate            | 26 : GregorianDiffDate\n");
  200.      WriteString("27 : HeisDiffDate              | 28 : JYearToScaliger\n");
  201.      WriteString("29 : GYearToScaliger           | 30 : HYearToScaliger\n");
  202.      WriteString("31 : ScaligerYearToJ           | 32 : ScaligerYearToG\n");
  203.      WriteString("33 : ScaligerYearToH           | 34 : JSYearToJD\n");
  204.      WriteString("35 : GSYearToJD                | 36 : HSYearToJD\n");
  205.      WriteString("37 : JDtoMJD                   | 38 : MJDtoJD\n");
  206.      WriteString("39 : JulianToJD                | 40 : GregorianToJD\n");
  207.      WriteString("41 : HeisToJD                  | 42 : TimeToJD\n");
  208.      WriteString("43 : JDToTime                  | 44 : GregorianMoonAge\n");
  209.      WriteString("45 : GregorianEaster           | 46 : TimeZoneFactor\n");
  210.      WriteString("47 : LMT                       | 48 : TimeToSec\n");
  211.      WriteString("49 : SecToTime                 | 50 : JulianWeek\n");
  212.      WriteString("51 : GregorianWeek             | 52 : HeisWeek\n");
  213.      WriteString("00 : Quit\n");
  214.      WriteString("It's your turn: "); ReadCard(input);
  215.      WriteString("----------------------------------------------------------------\n");
  216.      REPEAT
  217.        CASE input OF
  218.           0 : ;|
  219.           1 : IF Date.JulianLeapYear(readintyear()) THEN
  220.               WriteString("TRUE\n");;
  221.             ELSE
  222.               WriteString("FALSE\n");
  223.             END;|
  224.           2 : IF Date.GregorianLeapYear(readintyear()) THEN
  225.               WriteString("TRUE\n");;
  226.             ELSE
  227.               WriteString("FALSE\n");
  228.             END;|
  229.           3 : IF Date.HeisLeapYear(readintyear()) THEN
  230.               WriteString("TRUE\n");;
  231.             ELSE
  232.               WriteString("FALSE\n");
  233.             END;|
  234.           4 : WriteCard(Date.JulianMonthDays(readshortcardmonth(),readintyear()),3);
  235.             WriteLn;|
  236.           5 : WriteCard(Date.GregorianMonthDays(readshortcardmonth(),readintyear()),3);
  237.             WriteLn;|
  238.           6 : WriteCard(Date.HeisMonthDays(readshortcardmonth(),readintyear()),3);
  239.             WriteLn;|
  240.           7 : WriteCard(Date.JulianYearDays(readintyear()),4);
  241.               WriteLn;|
  242.           8 : WriteCard(Date.GregorianYearDays(readintyear()),4);
  243.               WriteLn;|
  244.           9 : WriteCard(Date.HeisYearDays(readintyear()),4);
  245.               WriteLn;|
  246.          10 : WriteInt(Date.JulianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  247.               WriteLn;|
  248.          11 : WriteInt(Date.GregorianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  249.               WriteLn;|
  250.          12 : WriteInt(Date.HeisDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  251.               WriteLn;|
  252.          13 : IF Date.JulianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  253.               WriteString("TRUE\n");
  254.             ELSE
  255.               WriteString("FALSE\n");
  256.             END;|
  257.          14 : IF Date.GregorianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  258.               WriteString("TRUE\n");
  259.             ELSE
  260.               WriteString("FALSE\n");
  261.             END;|
  262.          15 : IF Date.HeisDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  263.               WriteString("TRUE\n");
  264.             ELSE
  265.               WriteString("FALSE\n");
  266.             END;|
  267.          16 : wd := Date.JulianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  268.           CASE wd OF
  269.             Date.dayerr    : WriteString("dayerr!\n");|
  270.             Date.Monday    : WriteString("Monday\n");|
  271.             Date.Tuesday   : WriteString("Tuesday\n");|
  272.             Date.Wednesday : WriteString("Wednesday\n");|
  273.             Date.Thursday  : WriteString("Thursday\n");|
  274.             Date.Friday    : WriteString("Friday\n");|
  275.             Date.Saturday  : WriteString("Saturday\n");|
  276.             Date.Sunday    : WriteString("Sunday\n");
  277.               ELSE
  278.                 WriteString("Illegal Code!\n");
  279.               END;|
  280.          17 : wd := Date.GregorianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  281.           CASE wd OF
  282.             Date.dayerr    : WriteString("dayerr!\n");|
  283.             Date.Monday    : WriteString("Monday\n");|
  284.             Date.Tuesday   : WriteString("Tuesday\n");|
  285.             Date.Wednesday : WriteString("Wednesday\n");|
  286.             Date.Thursday  : WriteString("Thursday\n");|
  287.             Date.Friday    : WriteString("Friday\n");|
  288.             Date.Saturday  : WriteString("Saturday\n");|
  289.             Date.Sunday    : WriteString("Sunday\n");
  290.               ELSE
  291.                 WriteString("Illegal Code!\n");
  292.               END;|
  293.          18 : wd := Date.HeisWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  294.           CASE wd OF
  295.             Date.dayerr    : WriteString("dayerr!\n");|
  296.             Date.Monday    : WriteString("Monday\n");|
  297.             Date.Tuesday   : WriteString("Tuesday\n");|
  298.             Date.Wednesday : WriteString("Wednesday\n");|
  299.             Date.Thursday  : WriteString("Thursday\n");|
  300.             Date.Friday    : WriteString("Friday\n");|
  301.             Date.Saturday  : WriteString("Saturday\n");|
  302.             Date.Sunday    : WriteString("Sunday\n");
  303.               ELSE
  304.                 WriteString("Illegal Code!\n");
  305.               END;|
  306.          19 : WriteCard(Date.JulianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  307.           WriteLn;|
  308.          20 : WriteCard(Date.GregorianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  309.           WriteLn;|
  310.          21 : WriteCard(Date.HeisDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  311.           WriteLn;|
  312.          22 : WriteCard(Date.JulianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  313.           WriteLn;|
  314.          23 : WriteCard(Date.GregorianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  315.           WriteLn;|
  316.          24 : WriteCard(Date.HeisDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  317.           WriteLn;|
  318.          25 : Date.JulianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  319.               WriteCard(d,2); WriteString("."); WriteCard(m,2); WriteString("."); WriteInt(y,4); WriteLn;|
  320.          26 : Date.GregorianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  321.               WriteCard(d,2); WriteString("."); WriteCard(m,2); WriteString("."); WriteInt(y,4); WriteLn;|
  322.          27 : Date.HeisDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  323.               WriteCard(d,2); WriteString("."); WriteCard(m,2); WriteString("."); WriteInt(y,4); WriteLn;|
  324.          28 : WriteCard(Date.JYearToScaliger(readintyear()),10);
  325.               WriteLn;|
  326.          29 : WriteCard(Date.GYearToScaliger(readintyear()),10);
  327.               WriteLn;|
  328.          30 : WriteCard(Date.HYearToScaliger(readintyear()),10);
  329.               WriteLn;|
  330.          31 : WriteInt(Date.ScaligerYearToJ(readcardyear()),5);
  331.               WriteLn;|
  332.          32 : WriteInt(Date.ScaligerYearToG(readcardyear()),5);
  333.               WriteLn;|
  334.          33 : WriteInt(Date.ScaligerYearToH(readcardyear()),5);
  335.               WriteLn;|
  336.          34 : WriteCard(Date.JSYearToJD(readcardyear()),10);
  337.               WriteLn;|
  338.          35 : WriteCard(Date.GSYearToJD(readcardyear()),10);
  339.               WriteLn;|
  340.          36 : WriteCard(Date.HSYearToJD(readcardyear()),10);
  341.               WriteLn;|
  342.          37 : WriteCard(Date.JDtoMJD(readlongcarddays()),10);
  343.               WriteLn;|
  344.          38 : WriteCard(Date.MJDtoJD(readlongcarddays()),10);
  345.               WriteLn;|
  346.          39 : WriteCard(Date.JulianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  347.               WriteLn;|
  348.          40 : WriteCard(Date.GregorianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  349.               WriteLn;|
  350.          41 : WriteCard(Date.HeisToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  351.               WriteLn;|
  352.          42 : WriteReal(Date.TimeToJD(readshortcardhour(),readshortcardmin(),readshortcardsec()),20,10);
  353.               WriteLn;|
  354.          43 : Date.JDToTime(readrealtime(),h,m,s);
  355.               WriteCard(h,2); WriteString(":"); WriteCard(m,2); WriteString(":"); WriteCard(s,2); WriteLn;|
  356.          44 : WriteCard(Date.GregorianMoonAge(readshortcardday(),readshortcardmonth(),readintyear()),2);
  357.               WriteLn;|
  358.          45 : Date.GregorianEaster(readintyear(),d,m);
  359.               WriteCard(d,2); WriteString("."); WriteCard(m,2); WriteString("."); WriteLn;|
  360.          46 : WriteInt(Date.TimeZoneFactor(readshortintdegree()),2); WriteLn;|
  361.          47 : WriteInt(Date.LMT(readlongcardsecs(),readrealmeridian(),readrealpos()),10); WriteLn;|
  362.          48 : WriteCard(Date.TimeToSec(readshortcardhour(),readshortcardmin(),readshortcardsec()),10); WriteLn;|
  363.          49 : Date.SecToTime(readlongcardsecs(),h,m,s);
  364.               WriteCard(h,2); WriteString(":"); WriteCard(m,2); WriteString(":"); WriteCard(s,2); WriteLn;|
  365.          50 : WriteCard(Date.JulianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); WriteLn;|
  366.          51 : WriteCard(Date.GregorianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); WriteLn;|
  367.          52 : WriteCard(Date.HeisWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); WriteLn;
  368.        ELSE
  369.          WriteString("Wong number! Try again!\n");
  370.        END;
  371.        IF input > 0 THEN
  372.          WriteString("0 : Menue; >0 : test again - ");
  373.          ReadCard(repeat);
  374.        ELSE
  375.          repeat := 0;
  376.        END;
  377.      UNTIL repeat = 0;
  378.    UNTIL input = 0;
  379.  END test.
  380.